/**
 * Created by PanJiaChen on 16/11/18.
 */

/**
 * @param {string} path
 * @returns {Boolean}
 */
export function isExternal(path) {
  return /^(https?:|mailto:|tel:)/.test(path);
}

/**
 * @param {string} str
 * @returns {Boolean}
 */
export function validUsername(str) {
  const valid_map = ["admin", "editor"];
  return valid_map.indexOf(str.trim()) >= 0;
}

// 验证手机号
export function isValidPhoneNumber(phoneNumber) {
  const phoneRegex = /^1[3456789]\d{9}$/;
  return phoneRegex.test(phoneNumber);
}
// 验证姓名
export function isValidNameRegex(name) {
  const nameRegex = /^[\u4e00-\u9fa5]([\u4e00-\u9fa5·]{1,})$/;
  return nameRegex.test(name);
}
// 验证证件号
export function isIdCardRegex(ID) {
  const idCardRegex =
    /^[1-9]\d{5}(18|19|20)\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}([0-9]|X)$/;
  return idCardRegex.test(ID);
}
